package com.yidu.qianfeng.service.impl;

import com.yidu.qianfeng.common.bean.Vehicle.CarInfo;
import com.yidu.qianfeng.common.bean.client.Consignee;
import com.yidu.qianfeng.common.bean.client.Shipper;
import com.yidu.qianfeng.common.bean.company.EmpInfo;
import com.yidu.qianfeng.common.bean.company.Subst;
import com.yidu.qianfeng.common.bean.transport.TrackWaybill;
import com.yidu.qianfeng.common.bean.transport.TrackWrap;
import com.yidu.qianfeng.common.bean.transport.TransportProtocol;
import com.yidu.qianfeng.common.bean.transport.TruckLoading;
import com.yidu.qianfeng.common.bean.waybill.Waybill;
import com.yidu.qianfeng.common.bean.waybill.WaybillWrap;
import com.yidu.qianfeng.mapper.TruckMapper;
import com.yidu.qianfeng.service.TruckServiceInter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service("truckServiceimpl")
public class TruckServiceimpl implements TruckServiceInter {

    @Resource(name = "truckMapper")
    private TruckMapper truckMapper;

    @Override
    public List<TrackWrap> selectwaybill(int page, int limit, TrackWrap waybill, String status) {
        return truckMapper.selectwaybill(page,limit,waybill,status);
    }

    @Override
    public List<Subst> selectsubtype() {
        return truckMapper.selectsubtype();
    }

    @Override
    public Subst selectsubtypeone(CarInfo info) {
        return truckMapper.selectsubtypeone(info);
    }

    @Override
    public boolean login(String username,String password){
        EmpInfo user = truckMapper.selectUser (username);
        BCryptPasswordEncoder encode = new BCryptPasswordEncoder();
        System.out.println(encode.matches(password,user.getEmpPassword()));
        if (encode.matches(password,user.getEmpPassword())){
            return true;
        }
        return false;
    }

    @Override
    public int selectpand(String id) {
        return truckMapper.selectpand(id);
    }

    @Override
    public List<TrackWaybill> selectwaybilllist(String waybillConsignNum) {
        return truckMapper.selectwaybilllist( waybillConsignNum);
    }

    @Override
    public int selectdelnum(String str) {
        return truckMapper. selectdelnum(str);
    }

    @Override
    public List<Waybill> selectsavecar(int page, int limit,String id) {
        return truckMapper.selectsavecar(page,limit,id);
    }

    @Override
    public List<Waybill> screenselect() {
        return truckMapper.screenselect();
    }

    @Override
    public List<Shipper> departselect() {
        return truckMapper.departselect();
    }

    @Override
    public  List<Waybill> selectcar(int page, int limit) {
        return truckMapper.selectcar(page,limit);
    }

    @Override
    public int changeState(int id) {
        return truckMapper.changeState( id);
    }

    @Override
    public int removecar(int id) {
        return truckMapper. removecar(id);
    }

    @Override
    public int savecar(int id) {
        return truckMapper.savecar(id);
    }

    @Override
    public int removecartwo(int id) {
        return truckMapper.removecartwo(id);
    }

    @Override
    public int insertcar(TruckLoading loading) {
        return truckMapper.insertcar(loading);
    }

    @Override
    @Transactional
    public int insertprotocol(TransportProtocol pro) {
        return truckMapper.insertprotocol(pro);
    }

    @Override
    public Waybill selectsavecartow(int id) {
        return truckMapper.selectsavecartow( id);
    }

    @Override
    public List<TruckLoading> selecttruckloading(int i, int limit) {
        return truckMapper.selecttruckloading(i,limit);
    }

    @Override
    public int deletecarone(int id) {
        return truckMapper.deletecarone(id);
    }

    @Override
    public int updatecar(TruckLoading loading) {
        return truckMapper.updatecar(loading);
    }

    @Override
    public int selectcarnum() {
        return truckMapper.selectcarnum();
    }

    @Override
    public int selectwaybillnum(String status) {
        return truckMapper.selectwaybillnum(status);
    }

    @Override
    public int updatecarstatus(String ids) {
        return truckMapper.updatecarstatus(ids);
    }

    @Override
    public int selectcarnumtwo() {
        return truckMapper.selectcarnumtwo();
    }

    @Override
    public List<TrackWrap> depatlist(int page, int limit,TrackWrap wrap) {
        return truckMapper.depatlist(page,limit,wrap);
    }

    @Override
    public int depatlistnum() {
        return truckMapper.depatlistnum();
    }

    @Override
    public int relation(String ids,String trucknum) {
        return truckMapper.relation(ids,trucknum);
    }

    @Override
    public String selecttrucknum(String ids) {
        return truckMapper.selecttrucknum(ids);
    }

    @Override
    public int deleterelation(int str) {
        return truckMapper.deleterelation(str);
    }

    @Override
    public List<TruckLoading> selectcarlist(String id) {
        return truckMapper.selectcarlist(id);
    }

    @Override
    public int selectdriver(CarInfo info) {
        return truckMapper.selectdriver(info);
    }

    @Override
    public int insertdriver(CarInfo info) {
        return truckMapper.insertdriver(info);
    }

    @Override
    public int selectconsignee(Consignee con) {
        return truckMapper.selectconsignee(con);
    }

    @Override
    public int insertconsignee(Consignee con) {
        return truckMapper.insertconsignee(con);
    }

    @Override
    public int deletecarlist(String parseInt) {
        return truckMapper.deletecarlist(parseInt);
    }

    @Override
    public int updateprotocol(TransportProtocol t) {
        return truckMapper.updateprotocols(t);
    }

    @Override
    public int updatecarone(int id) {
        return truckMapper.updatecarone(id);
    }

    @Override
    public List<TrackWrap> selectdriverinfo(String carDriver,String startingSubst) {
        return truckMapper.selectdriverinfo(carDriver,startingSubst);
    }

    @Override
    public List<Consignee> selectconsinfo(String consiCom) {
        return truckMapper.selectconsinfo(consiCom);
    }
}
